/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ie.tcd.cs.railtickets.server.domain;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Wenbo Sun
 */
@Entity
@Table(name = "route_station")
public class RouteStation implements Serializable{

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "route_station_id")
    private long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "route_id")
    private Route route;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "station_id")
    private Station station;

    @Column(name = "sequence_num")
    private int sequenceNum;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "routeStation")
    private Set<SeatState> seatStates;

    public RouteStation() {
    }

    public RouteStation(long id) {
        this.id = id;
    }

    public RouteStation(Route route, Station station, int sequenceNum) {
        this.route = route;
        this.station = station;
        this.sequenceNum = sequenceNum;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Route getRoute() {
        return route;
    }

    public void setRoute(Route route) {
        this.route = route;
    }

    public int getSequenceNum() {
        return sequenceNum;
    }

    public void setSequenceNum(int sequenceNum) {
        this.sequenceNum = sequenceNum;
    }

    public Station getStation() {
        return station;
    }

    public void setStation(Station station) {
        this.station = station;
    }

    public Set<SeatState> getSeatStates() {
        return seatStates;
    }

    public void setSeatStates(Set<SeatState> seatStates) {
        this.seatStates = seatStates;
    }

 
}
